package com.wwx.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.wwx.validator.annotation.Gender;
import com.wwx.validator.group.AddGroup;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.Valid;
import javax.validation.constraints.*;
import java.util.Date;
import java.util.List;

/**
 * @author 王伟欣
 * @version V1.0
 * @email w17731138318@126.com
 * @creator 2023-02-11 10:34
 * @company 晶品科技
 * @copyright 晶品科技 · 石家庄 · 技术二部
 */
@Data
public class UserEntity {

	@NotBlank(message = "{name.require}", groups = AddGroup.class)
	@Length(message = "名称长度范围 {min} - {max} 字符",min = 6,max = 10)
	private String name;
	@Length(message = "密码长度范围 {min} - {max} 字符",min = 6,max = 12)
	private String password;

	@NotNull(message = "请输入年龄")
	@Range(message = "年龄范围为 {min} 到 {max} 之间", min = 1, max = 100)
	private Integer age;

	@Gender(message = "性别：男 或 女")
	private String sex;

	@NotNull(message = "deposit不能为空")
	@DecimalMin(message = "不能小于  {value}",  value ="10")
	@DecimalMax(message = "不能大于  {value}",  value ="100")
	private Double deposit;

	@Email(message = "邮箱格式不合法")
	@NotBlank(message = "邮箱不能为空")
	private String email;


	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private Date birthday;
	@Valid
	@NotEmpty(message = "收货地址不能为空")
	@Size(message = "请最少录入{min}收货地址" ,min = 1)
	private List<AddressEntity> address;
}
